/*
 * @lc app=leetcode.cn id=345 lang=cpp
 *
 * [345] 反转字符串中的元音字母
 */

// @lc code=start
class Solution {
public:
    string reverseVowels(string s) {
        std::string c = "aeiouAEIOU";
        int l = s.find_first_of(c), r = s.find_last_of(c);
        while (l < r) {
            if (c.find(s[l]) == std::string::npos) {
                l++;
                continue;
            }

            if (c.find(s[r]) == std::string::npos) {
                r--;
                continue;
            }

            char t = s[l];
            s[l] = s[r];
            s[r] = t;
            l++;
            r--;
        }

        return s;
    }
};
// @lc code=end

